package com.example.Dao;

import com.example.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    //查询用户是否存在/用户登录
    @Select("select * from user where phoneNumber = #{phone} or email = #{email}")
    User selectUser(String phone,String email);

    @Select("select id, username,create_time , user_image, phoneNumber, email from user where phoneNumber = #{phone}")
    User selectUser1(String phone);

    //用户注册
    @Insert("insert into user( phoneNumber, email,password,create_time) " +
            "values (#{phone},#{email},#{password},NOW())")
    void addUser(String phone, String email, String password);


    @Select("select * from user where id = #{createId} and password = #{oldPassword}")
    User seletcRePs(String oldPassword, Integer createId);

    //修改密码
    @Update("update user set password = #{newPassword} where id = #{createId}")
    void updataPs(String newPassword, Integer createId);
}
